package net.ccbluex.liquidbounce.ui.client.hud.element.elements

import me.utils.render.RoundedUtil
import me.utils.render.ShadowUtils
import net.ccbluex.liquidbounce.LiquidBounce
import net.ccbluex.liquidbounce.features.module.modules.render.HUD
import net.ccbluex.liquidbounce.features.module.modules.render.PictureColor
import net.ccbluex.liquidbounce.features.module.modules.render.PictureColor2
import net.ccbluex.liquidbounce.features.module.modules.render.RenderPosHelper
import net.ccbluex.liquidbounce.font.CFontLoad
import net.ccbluex.liquidbounce.ui.client.hud.element.Border
import net.ccbluex.liquidbounce.ui.client.hud.element.Element
import net.ccbluex.liquidbounce.ui.client.hud.element.ElementInfo
import net.ccbluex.liquidbounce.ui.client.hud.element.elements.utils.QQLogoHelper2
import net.ccbluex.liquidbounce.utils.blur.BlurBuffer
import net.ccbluex.liquidbounce.utils.render.ColorUtils
import net.ccbluex.liquidbounce.utils.render.RenderUtils
import net.ccbluex.liquidbounce.utils.render.Stencil
import net.ccbluex.liquidbounce.value.BoolValue
import net.ccbluex.liquidbounce.value.FloatValue
import net.ccbluex.liquidbounce.value.IntegerValue
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.Gui
import net.minecraft.client.renderer.GlStateManager
import net.minecraft.client.renderer.OpenGlHelper
import org.lwjgl.opengl.GL11
import java.awt.Color
import java.math.BigDecimal
import java.net.URL
import java.util.*
import javax.imageio.ImageIO
import kotlin.math.pow

@ElementInfo(name = "RenderFps")
class RenderFps : Element() {
    /**
     * Draw the entity.
     */
    private val shadow = BoolValue("Shadow", true)

    val color = LiquidBounce.moduleManager.getModule(PictureColor::class.java) as PictureColor
    val color2 = LiquidBounce.moduleManager.getModule(PictureColor2::class.java) as PictureColor2
    var blurmodule = LiquidBounce.moduleManager.getModule(HUD::class.java) as HUD
    var renpos = LiquidBounce.moduleManager.getModule(RenderPosHelper::class.java) as RenderPosHelper
    override fun drawElement(): Border? {
        var bd: BigDecimal = BigDecimal(mc.thePlayer!!.health.toDouble())
        bd=bd.setScale(1, BigDecimal.ROUND_FLOOR);
        RoundedUtil.drawRound(0f,0f,60f,16f, 2f,Color(0, 0, 0, 200))
        CFontLoad.foricotwo24.drawStringWithShadow("I",5.00,5.00.toDouble(),Color.white.rgb)
        CFontLoad.for18.drawStringWithShadow(Minecraft.getDebugFPS().toString()+" Fps",21.00,7.toDouble().toDouble(),Color.white.rgb)
        if (shadow.get()){
            GL11.glTranslated(-renderX, -renderY, 0.0)
            GL11.glScalef(1F, 1F, 1F)
            GL11.glPushMatrix()
            ShadowUtils.shadow(8f, {
                GL11.glPushMatrix()
                GL11.glTranslated(renderX, renderY, 0.0)
                GL11.glScalef(scale, scale, scale)
                RenderUtils.originalRoundedRect(
                    -0.8f,
                    -0.8f,60.70f,16.80f,
                    2.20f,Color(0,0,0,210).rgb)


                GL11.glPopMatrix()
            }, {

                GL11.glPushMatrix()
                GL11.glTranslated(renderX, renderY, 0.0)
                GL11.glScalef(scale, scale, scale)
                GlStateManager.enableBlend()
                GlStateManager.disableTexture2D()
                GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0)

                RenderUtils.originalRoundedRect(
                    -0.8f,
                    -0.8f,60.70f,16.80f,
                    2.20f,Color(blurmodule.shadowred.get(),blurmodule.shadowgreen.get(),blurmodule.shadowblue.get(),blurmodule.shadowalpha.get()).rgb)
                GlStateManager.enableTexture2D()
                GlStateManager.disableBlend()
                GL11.glPopMatrix()
            })
            GL11.glPopMatrix()
            GL11.glScalef(scale, scale, scale)
            GL11.glTranslated(renderX, renderY, 0.0)
        }
        return Border(2.0f - 15.0f, 2.0f - 18.0f, 2.0f + 100f, 2.0f + 50.0f)
    }




}